package com.factors.TangChuan.Peer_Influence;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class ExamScoreFilterMapper extends Mapper<LongWritable, Text, Text, IntWritable> {

    private static final IntWritable one = new IntWritable(1);

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String[] columns = value.toString().split(",");
        if (columns.length >= 20) {
            try {
                float examScore = Float.parseFloat(columns[19]);
                String peerInfluence = columns[13];
                if (examScore > 80) {
                    context.write(new Text(peerInfluence), one);
                }
            } catch (NumberFormatException e) {

            }
        }
    }
}